#include							"ClientManager.h"

ClientManager::ClientManager()
{
	_it = _client.begin();
}

ClientManager::~ClientManager()
{
	for (std::map<unsigned int, Client*>::iterator it = _client.begin(); it != _client.end(); ++it)
		delete (*it).second;
}

Client								*ClientManager::operator[](unsigned int id)
{
	if (_client.find(id) != _client.end())
		return _client[id];
	return NULL;
}

void								ClientManager::addClient(unsigned int id, Client *client)
{
	_client[id] = client;
}

Client								*ClientManager::getNextClient()
{
	if (_it == _client.end())
	{
		_it = _client.begin();
		return NULL;
	}
	Client							*client = (*_it).second;
	++_it;
	return client;
}

void								ClientManager::start()
{
	_it = _client.begin();
}

unsigned int						ClientManager::size() const
{
	return _client.size();
}